package com.nanychuan.blogbase.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.util.Enumeration;

/**
 * @author 往
 * 负责后台页面的统一跳转
 */
@Controller
public class ViewController {
    @RequestMapping("/blog/toView/{firstView}/{secondView}")
    public String toView(@PathVariable String firstView, @PathVariable String secondView,
                         HttpServletRequest request){
        //获取前台所有参数的名字
        Enumeration<String> names = request.getParameterNames();
        //遍历names
        while(names.hasMoreElements()){
            String name = names.nextElement();
            String value = request.getParameter(name);
            //设置到request域中
            request.setAttribute(name,value);
        }
        //RestFul风格跳转页面
        //File.separator代表 "/"
        return firstView+ File.separator+secondView;
    }
}
